<template>
<div class="edit-my-article-warp">
    <markdownEditor v-if="orgDataIsReady&&tagListIsReady" :tagList="tagListData" :isUpdate="true" :orgMarkDownContent="orgMarkDownContentData" :orgArticleTags="orgArticleTagsData" :orgArticleTitle="orgArticleTitleData" :orgArticleId="$route.query.articleId"></markdownEditor>
</div>
</template>

<script>
import markdownEditor from '@/components/writeBlogComponents/markdownEditor';
import {request} from '@/network/request.js';
export default {
    name:"EditMyArticle",
    components:{
        markdownEditor
    },
    data(){
        return {
            tagListData:[],
            orgMarkDownContentData:"",
            orgArticleTagsData:[],
            orgArticleTitleData:"",
            orgArticleIdData:"",
            orgDataIsReady:false,
            tagListIsReady:false
        }
    },
    created(){
        //获取tagList的数据
        request({
            url:"/tag/tagList/"+this.$store.getters.getCurrentUser.userId+"/0"
        }).then(res=>{
        // console.log(res);
            this.tagListData=res.data.tagList;
            this.tagListIsReady=true;
        }).catch(err=>{
            console.log(err);
        });
        //获取原来文章的数据
        request({
            url:"/article/articleDetail/"+this.$route.query.articleId
        }).then(res=>{
            console.log(res);
            this.orgMarkDownContentData=res.data.articleDetail.articleMarkDownContent;
            this.orgArticleTagsData=res.data.articleDetail.articleTagIdList;
            this.orgArticleTitleData=res.data.articleDetail.articleTitle;
            this.orgArticleIdData=res.data.articleDetail.articleId;
            this.orgDataIsReady=true;
        }).catch(err=>{
            console.log(err);
        })
    }
}
</script>

<style>
.edit-my-article-warp {
    min-height: 800px;
}
</style>